<?php
namespace API\Controller;
use Think\Controller;
class GoodsController extends CommonController {
	//选择一级商品分类载入对应二级商品分类信息 
	// true表示载入成功 false失败
	//标识码 0表示失败 1表示成功
	public function loadtwosort(){
		$TwoSort = M('Twosort');
		$sort_id = I("post.sortid");
		$TwoSortdata = $TwoSort->order("id ASC")->where("sortid={$sort_id}")->select(); 
		if (empty($TwoSortdata)) {
		             $this->response("载入二级商品分类信息",false,0,"二级商品分类信息为空");	
		}else{
			$this->response("载入二级商品分类信息",true,1,$TwoSortdata);
		}
	}
	//载入商品信息
	public function loadgoods(){
		$Goods = M('Goods');
		$goodsdata=$Goods->order("id ASC")->select();
		if (empty($goodsdata)) {
			$this->response("载入商品信息",false,0,"商品信息为空");
		}else{
			$Sort = M("Sort");
			$TwoSort = M("Twosort");
			$goodslist = array();
			foreach ($goodsdata as $val) {
				$val['sortname'] = $Sort->where("id = {$val['sortid']}")->getField("sortname");
				$val['twosortname'] = $TwoSort->where("id = {$val['twosortid']}")->getField("twosortname");
				$goodslist[ ] = $val;
			}
			$this->response("载入商品信息",true,1,$goodslist);
		}
	}
}